home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / btrename.bittorrent < prev    next >
Encoding:
Text File  |  2007-02-19  |  823 b   |  34 lines

  1. #! /usr/bin/python
  2.  
  3. # Written by Henry 'Pi' James
  4. # see LICENSE.txt for license information
  5.  
  6. from sys import *
  7. from os.path import *
  8. from sha import *
  9. from BitTorrent.bencode import *
  10.  
  11. NAME, EXT = splitext(basename(argv[0]))
  12. VERSION = '20021119'
  13.  
  14. print '%s %s - change the suggested filename in a .torrent file' % (NAME, VERSION)
  15. print
  16.  
  17. if len(argv) != 3:
  18.   print '%s file.torrent new.filename.ext' % argv[0]
  19.   print
  20.   exit(2) # common exit code for syntax error
  21.  
  22. metainfo_file = open(argv[1], 'rb')
  23. metainfo = bdecode(metainfo_file.read())
  24. metainfo_file.close()
  25. print 'old filename: %s' % metainfo['info']['name']
  26. metainfo['info']['name'] = argv[2]
  27. print 'new filename: %s' % metainfo['info']['name']
  28. metainfo_file = open(argv[1], 'wb')
  29. metainfo_file.write(bencode(metainfo))
  30. metainfo_file.close
  31. print
  32. print 'done.'
  33. print
  34.